package com.dhy.replugin

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.Toast
import com.qihoo360.replugin.RePlugin
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val name = "com.dhy.plugin"
        val cls = "com.dhy.plugin.PluginActivity"
        RePlugin.preload(name)
        button.setOnClickListener {
            val intent = RePlugin.createIntent(name, cls)
            if (!RePlugin.startActivity(this, intent)) {
                Toast.makeText(this, "启动失败", Toast.LENGTH_LONG).show()
            }
        }
        image.setOnClickListener {
            val url = "https://i1.mifile.cn/a4/xmad_15627254995865_hbFzT.jpg"
            image.setImageURI(url)
        }
    }
}